<template>
  <ul class="tabbar-container">
    <li>
      <router-link tag="a" to="/home" @click="switchTab">
        <van-icon
          name="home-o"
          size="24px"
          class="icon"
          :color="$route.meta.num == 0 ? '#1989fa' : ''"
        />
        <span :class="$route.meta.num == 0 ? 'current' : ''">首页</span>
      </router-link>
    </li>
    <li>
      <router-link tag="a" to="/topic" @click="switchTab">
        <van-icon
          name="label-o"
          size="24px"
          class="icon"
          :color="$route.meta.num == 1 ? '#1989fa' : ''"
        />
        <span :class="$route.meta.num == 1 ? 'current' : ''">专题</span>
      </router-link>
    </li>
    <li>
      <router-link tag="a" to="/category" @click="switchTab">
        <van-icon
          name="apps-o"
          size="24px"
          class="icon"
          :color="$route.meta.num == 2 ? '#1989fa' : ''"
        />
        <span :class="$route.meta.num == 2 ? 'current' : ''">分类</span>
      </router-link>
    </li>
    <li>
      <router-link tag="a" to="/cart" @click="switchTab">
        <van-icon
          name="cart-o"
          size="24px"
          class="icon"
          :color="$route.meta.num == 3 ? '#1989fa' : ''"
        />
        <span :class="$route.meta.num == 3 ? 'current' : ''">购物车</span>
      </router-link>
    </li>
    <li>
      <router-link tag="a" to="/user" @click="switchTab">
        <van-icon
          name="user-o"
          size="24px"
          class="icon"
          :color="$route.meta.num == 4 ? '#1989fa' : ''"
        />
        <span :class="$route.meta.num == 4 ? 'current' : ''">我的</span>
      </router-link>
    </li>
  </ul>
</template>

<script>
export default {
  data() {
    return {};
  },
  methods: {
    switchTab(path) {
      console.log($route.meta.num);
      this.$router.push(`${$route.meta.path}`);
    },
  },
};
</script>

<style lang="less" scoped>
.tabbar-container {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: #fff;
  display: flex;
  justify-content: space-around;
  li {
    flex: 1;
    margin-top: 10px;
    a {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      .icon {
        margin-bottom: 5px;
      }
      .current {
        color: #1989fa;
      }
    }
  }
}
</style>